package com.example.test;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;


import com.example.test.util.ToastUtil;

import org.jetbrains.annotations.Nullable;


public class FxFragment2 extends Fragment {

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                             Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.fragment_me,container,false);
        TextView textView=view.findViewById(R.id.name);
        String name=getActivity().getIntent().getStringExtra("name");
        textView.setText(name);
        return view;


    }
//    private void change(View view){
//        Intent intent = new Intent(getActivity(),ModifyActivity.class);
//        startActivity(intent);
//    }


    @Override
    public void onActivityCreated(@android.support.annotation.Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        LinearLayout layout = getActivity().findViewById(R.id.btn);
        layout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String name=getActivity().getIntent().getStringExtra("name");
                String phone=getActivity().getIntent().getStringExtra("phone");
                Intent intent = new Intent(getActivity(), ModifyActivity.class);
                intent.putExtra("name",name);
                intent.putExtra("phone",phone);
                startActivity(intent);
            }
        });
        Button button = getActivity().findViewById(R.id.exit);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), MainActivity.class);
                ToastUtil.toastShort(getActivity(),"您已退出账号");
                startActivity(intent);
            }
        });
    }
}